home *** CD-ROM | disk | FTP | other *** search
/ Video Toaster 4.2 / Video Toaster v4.2.iso / arexx / modeler / lightswarm.lwm < prev    next >
Text File  |  1993-12-13  |  7KB  |  209 lines

  1. /* CMD: LightSwarm
  2.  *  Make cloud of lights from selected points on an object, save scene file.
  3.  *  Load null object parent and all lights with LW 'LoadFromScene' option.
  4.  * By Arnie Cachelin © 1993 NewTek Inc.
  5.  *  $VER: Fri Oct  1 12:58:17 1993
  6.  */
  7.     mxx="LWModelerARexx.port"
  8.     signal on error
  9.     signal on syntax
  10.     mxx_add = addlib(mxx,0)
  11.     call main
  12.     if (mxx_add) then call remlib(mxx)
  13.     exit
  14.  
  15.     syntax:
  16.     error:
  17.     t=Notify(1,'!Rexx Script Error','@'ErrorText(rc),'Line 'SIGL)
  18.     if (mxx_add) then call remlib(mxx)
  19.     exit
  20.  
  21.  
  22. main:
  23.   call sel_mode(USER)
  24.   num=xfrm_begin()
  25.   if num>399 then num=399  /* No more than 400 lights in a scene */
  26.   if num=0 then do
  27.     call notify(1,"No Points Selected!")
  28.     exit
  29.     end
  30.   MFile=getfilename("-- Save Scene --","RAM:")
  31.   if MFile ~="(none)" then filename=MFile
  32.   else exit
  33.  
  34.   sysnam = 'LightSwarm Scene: 'MFile
  35.   call req_begin sysnam
  36.   nam=req_addcontrol("Light Name",'s',20)
  37.   typ=req_addcontrol("Light Type ","CH","Distant Point Spot")
  38.   intn=req_addcontrol("Intensity (%)","N")
  39.   fal=req_addcontrol("Falloff (%)","N")
  40.   rgb=req_addcontrol("Color",'V')
  41.   flar=req_addcontrol("Lens Flare",'B')
  42.   fint=req_addcontrol("Flare Intensity (%)","N")
  43.   fdis=req_addcontrol("Flare Dissolve (%)","N")
  44.   shad=req_addcontrol("Shadow Casting",'B')
  45.   og=req_addcontrol("Outer Glow Light",'B')
  46.   call req_setval nam, "LightSwarm"
  47.   call req_setval typ, 2
  48.   call req_setval intn, 100.0000
  49.   call req_setval fal,  0.0000
  50.   call req_setval shad, 0
  51.   call req_setval flar, 1
  52.   call req_setval og, 1
  53.   call req_setval fint, 50.000
  54.   call req_setval fdis, 0.0000
  55.   call req_setval rgb, '255 255 255'
  56.   if (~req_post()) then do
  57.     call req_end
  58.     return
  59.   end
  60.   type.1=req_getval(typ)-1
  61.   name.1=req_getval(name)
  62.   int.1=req_getval(intn)/100
  63.   Fall.1=req_getval(fal)/100
  64.   FlInt.1=req_getval(fint)/100
  65.   FlDis.1=req_getval(fdis)/100
  66.   color.1=req_getval(rgb)
  67.   parse var color.1 r g b
  68.   color.1= r%1 g%1 b%1
  69.   shadow.1=req_getval(shad)
  70.   flare.1=req_getval(flar)
  71.   glow=req_getval(og)
  72.   if glow then do
  73.     call req_setval nam, name.1'_OG'
  74.     if (~req_post()) then glow=0
  75.     end
  76.   if glow then do
  77.     type.2=req_getval(typ)-1
  78.     name.2=req_getval(name)
  79.     int.2=req_getval(intn)/100
  80.     Fall.2=req_getval(fal)/100
  81.     FlInt.2=req_getval(fint)/100
  82.     FlDis.2=req_getval(fdis)/100
  83.     color.2=req_getval(rgb)
  84.     parse var color.2 r g b
  85.     color.2= r%1 g%1 b%1
  86.     shadow.2=req_getval(shad)
  87.     flare.2=req_getval(flar)
  88.     end
  89.   call req_end
  90.   say filename
  91.   if ~open(MotFile,filename,'W') then call Bummer("Can't open file "filename)
  92.   Call WriteStart()
  93.  
  94.   do i=1 to num
  95.     parse value xfrm_getpos(i) with x y z .
  96.     Call WriteLight(i,1)
  97.     if glow then Call WriteLight(i,2)
  98.     end
  99.   Call WriteEnd()
  100.   call Close(MotFile)
  101.   return
  102.  
  103. WriteStart:  PROCEDURE  EXPOSE MotFile
  104.   call writeln(MotFile,"LWSC")
  105.   call writeln(MotFile,"1")
  106.   call writeln(MotFile,"")
  107.   call writeln(MotFile,"FirstFrame 1")
  108.   call writeln(MotFile,"LastFrame 1")
  109.   call writeln(MotFile,"FrameStep 1")
  110.   call writeln(MotFile,"")
  111.   call writeln(MotFile,"LoadObject NullObject")
  112.   call writeln(MotFile,"ObjectMotion (unnamed)")
  113.   call writeln(MotFile,"  9")
  114.   call writeln(MotFile,"  1")
  115.   call writeln(MotFile,"  0.0 0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0")
  116.   call writeln(MotFile,"  0 0 0.0 0.0 0.0")
  117.   call writeln(MotFile,"EndBehavior 1")
  118.   call writeln(MotFile,"ShadowOptions 7")
  119.   call writeln(MotFile,"")
  120.   return
  121.  
  122. WriteEnd:  PROCEDURE  EXPOSE MotFile
  123.   call writeln(MotFile,"CameraMotion (unnamed)")
  124.   call writeln(MotFile,"  9")
  125.   call writeln(MotFile,"  1")
  126.   call writeln(MotFile,"  0.002420 24.997030 -144.084366 0.0 0.0 0.0 1.0 1.0 1.0")
  127.   call writeln(MotFile,"  0 0 0.0 0.0 0.0")
  128.   call writeln(MotFile,"EndBehavior 1")
  129.   call writeln(MotFile,"ZoomFactor 3.200000")
  130.   call writeln(MotFile,"RenderMode 2")
  131.   call writeln(MotFile,"RayTraceEffects 0")
  132.   call writeln(MotFile,"Resolution 1")
  133.   call writeln(MotFile,"Overscan 1")
  134.   call writeln(MotFile,"Antialiasing 0")
  135.   call writeln(MotFile,"AdaptiveSampling 1")
  136.   call writeln(MotFile,"AdaptiveThreshold 8")
  137.   call writeln(MotFile,"FilmSize 2")
  138.   call writeln(MotFile,"FieldRendering 0")
  139.   call writeln(MotFile,"MotionBlur 0")
  140.   call writeln(MotFile,"DepthOfField 0")
  141.   call writeln(MotFile,"")
  142.   call writeln(MotFile,"SolidBackdrop 1")
  143.   call writeln(MotFile,"BackdropColor 0 0 0")
  144.   call writeln(MotFile,"ZenithColor 0 40 80")
  145.   call writeln(MotFile,"SkyColor 120 180 240")
  146.   call writeln(MotFile,"GroundColor 50 40 30")
  147.   call writeln(MotFile,"NadirColor 100 80 60")
  148.   call writeln(MotFile,"FogType 0")
  149.   call writeln(MotFile,"DitherIntensity 1")
  150.   call writeln(MotFile,"AnimatedDither 0")
  151.   call writeln(MotFile,"")
  152.   call writeln(MotFile,"DataOverlayLabel ")
  153.   call writeln(MotFile,"")
  154.   call writeln(MotFile,"ViewMode 5")
  155.   call writeln(MotFile,"ViewAimpoint 0.000000 0.000000 0.000000")
  156.   call writeln(MotFile,"ViewDirection 0.000000 -0.174533 0.000000")
  157.   call writeln(MotFile,"ViewZoomFactor 3.200000")
  158.   call writeln(MotFile,"LayoutGrid 3")
  159.   call writeln(MotFile,"GridSize 50.000000")
  160.   call writeln(MotFile,"ShowObjects 1")
  161.   call writeln(MotFile,"ShowBones 0")
  162.   call writeln(MotFile,"ShowLights 1")
  163.   call writeln(MotFile,"ShowCamera 1")
  164.   call writeln(MotFile,"ShowMotionPath 1")
  165.   call writeln(MotFile,"ShowSafeAreas 0")
  166.   call writeln(MotFile,"ShowBGImage 0")
  167.   call writeln(MotFile,"ShowFogRadius 0")
  168.   call writeln(MotFile,"ShowRedraw 0")
  169.   return
  170.  
  171. /* Change the text in this routine to change lights produced */
  172. WriteLight: PROCEDURE EXPOSE MotFile x y z color. int. type. shadow. flare. name. Fall. FlInt. FlDis.
  173.   arg n, f
  174.   channels="  "||x y z||" 0.0 0.0 0.0 1.0 1.0 1.0"
  175.   spline="  0 0 0.0 0.0 0.0"
  176.   say channels spline
  177.   call writeln(MotFile,"AddLight")
  178.   call writeln(MotFile,"LightName "name.f||"."||n)
  179.   call writeln(MotFile,"LightMotion (unnamed)")
  180.   call writeln(MotFile,"  9") /* Channels */
  181.   call writeln(MotFile,"  1")
  182.   call writeln(MotFile,channels)
  183.   call writeln(MotFile,spline)
  184.   call writeln(MotFile,"EndBehavior 1")
  185.   call writeln(MotFile,"ParentObject 1") /* Our NULL Object */
  186.   call writeln(MotFile,"LightColor "color.f)
  187.   call writeln(MotFile,"LgtIntensity "int.f)
  188.   call writeln(MotFile,"LightType "type.f)
  189.   call writeln(MotFile,"Falloff "Fall.f)
  190.   if flare~=0 then do
  191.     call writeln(MotFile,"LensFlare 1")
  192.     call writeln(MotFile,"FlareIntensity "FlInt.f)
  193.     call writeln(MotFile,"FlareDissolve "FlDis.f)
  194.     call writeln(MotFile,"LensFlareFade 4")     /* You'll have to play around  */
  195.     call writeln(MotFile,"LensFlareOptions 33") /* figure these two out... */
  196.     end
  197.   else call writeln(MotFile,"LensFlare 0")
  198.   if shadow.f~=0 then  call writeln(MotFile,"ShadowCasting 1")
  199.   else   call writeln(MotFile,"ShadowCasting 0")
  200.  
  201.   call writeln(MotFile,"")
  202.   return
  203.  
  204. Bummer:
  205.  ARG etxt
  206.     t=Notify(1,'!Rexx Script Error','@'ETxt)
  207.  exit
  208.  
  209.